/* PPSWrapper

 * Copyright (C) 2009- Luo Jinghua <sunmoon1997@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more
 */
#define _GNU_SOURCE
#include <dlfcn.h>

#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>

#include <stdio.h>

int msgget (key_t key, int msgflg)
{
  static int (*old_msgget)(key_t, int);
  
  if (!old_msgget)
  	old_msgget = dlsym (RTLD_NEXT, "msgget");

  //printf ("msgget(0x%x, 0x%x)\n", key, msgflg);
  //printf ("changed to msgget(0x%x, 0x%x)\n", key, msgflg | 0600);
   return old_msgget (key, msgflg | 0600);
}
